//////////////////////////////////////////////////////////////////////////////////
//	File Name:	Weapon.cpp
//	Author	 :	Yuri Oyoko
//	Purpose	 :	The weapon class defines the weapon currently being used
//////////////////////////////////////////////////////////////////////////////////

#include "Weapon.h"
#include "SoundManager.h"

Weapon::Weapon()
{
	theManager = SoundManager::GetInstance();
	Timer = 0;
	FireRate = 0;
}
Weapon::~Weapon()
{
}
void Weapon::FireWeapon()
{
	if(CurrentClipAmmo > 0)
	{
		CurrentClipAmmo--;
		//Play weapon sound firing
		switch(WeaponType)
		{
		case PISTOL:
			{
				theManager->PlayASound(theManager->PistolFireSound);
			}
			break;
		case UZI:
			{
				theManager->PlayASound(theManager->UziFireSound);
			}
			break;
		case ASSAULT_RIFLE:
			{
				theManager->PlayASound(theManager->AssaultRifleFireSound);
			}
			break;
		case SHOTGUN:
			{
				theManager->PlayASound(theManager->ShotgunFireSound);
			}
			break;
		case AUTOSHOTGUN:
			{
				theManager->PlayASound(theManager->AutoShotgunFireSound);
			}
			break;
		case HUNTING_RIFLE:
			{
				theManager->PlayASound(theManager->HuntingRifleFireSound);
			}
			break;
		}
	}

	else
	{
		//Play empty clip sound
		switch(WeaponType)
		{
		case PISTOL:
			{
				theManager->PlayASound(theManager->PistolEmptyClipSound);
			}
			break;
		case UZI:
			{
				theManager->PlayASound(theManager->UziEmptyClipSound);
			}
			break;
		case ASSAULT_RIFLE:
			{
				theManager->PlayASound(theManager->AssaultRifleEmptyClipSound);
			}
			break;
		case HUNTING_RIFLE:
			{
				theManager->PlayASound(theManager->HuntingRifleEmptyClipSound);
			}
			break;
		}
	}
}
void Weapon::ReloadWeapon()
{
	if(TotalAmmo >= ClipCapacity)
	{
		TotalAmmo -= ClipCapacity;
		CurrentClipAmmo = ClipCapacity;
		switch(WeaponType)
		{
		case PISTOL:
			{
				theManager->PlayASound(theManager->PistolReloadSound);
			}
			break;
		case UZI:
			{
				theManager->PlayASound(theManager->UziReloadSound);
			}
			break;
		case ASSAULT_RIFLE:
			{
				theManager->PlayASound(theManager->AssaultRifleReloadSound);
			}
			break;
		case SHOTGUN:
			{
				theManager->PlayASound(theManager->ShotgunReloadSound);
			}
			break;
		case AUTOSHOTGUN:
			{
				theManager->PlayASound(theManager->AutoShotgunReloadSound);
			}
			break;
		case HUNTING_RIFLE:
			{
				theManager->PlayASound(theManager->HuntingRifleReloadSound);
			}
			break;
		}
		
	}
	else
	{
		CurrentClipAmmo = TotalAmmo;
		TotalAmmo = 0;
		switch(WeaponType)
		{
		case PISTOL:
			{
				theManager->PlayASound(theManager->PistolReloadSound);
			}
			break;
		case UZI:
			{
				theManager->PlayASound(theManager->UziReloadSound);
			}
			break;
		case ASSAULT_RIFLE:
			{
				theManager->PlayASound(theManager->AssaultRifleReloadSound);
			}
			break;
		case SHOTGUN:
			{
				theManager->PlayASound(theManager->ShotgunReloadSound);
			}
			break;
		case AUTOSHOTGUN:
			{
				theManager->PlayASound(theManager->AutoShotgunReloadSound);
			}
			break;
		case HUNTING_RIFLE:
			{
				theManager->PlayASound(theManager->HuntingRifleReloadSound);
			}
			break;
		}
	}

}

void Weapon::Update(float ElapsedTime)
{
	Timer += ElapsedTime;
	if(Timer >= 0.5f)
		Timer = 0;
}
